var con = require('./BaseModel')();
exports.getProductLimit = function(limit,callback){
     var sql = "select * from base_goods ORDER BY sort limit 0,"+limit;
     con.query(sql,function(err, rows, fields) {
		   callback(rows);
	 });
}
exports.getProductById = function(goods_id,callback){
	var sql = "select * from base_goods where goods_id = '"+goods_id+"'";
     con.query(sql,function(err, rows, fields) {
		   callback(rows);
	 });
}
exports.getProductList = function(where,callback){
	var page      = where.page?where.page:1;
	var className = where.className;
	var num       =  where.num?where.num:16;
	var start =  num*(page-1); 
	var sql = "select * from base_goods limit "+start+","+num;
	if(className){
		var sql = "select * from base_goods where class = '"+className+"' limit "+start+","+num;
	}
	con.query(sql,function(err,rows,fields){
		callback(rows);
	})
}
exports.getProductCountByClass = function(className,callback){
   var sql = "select count(*) as count from base_goods ";
	if(className){
		var sql = "select count(*) as count from base_goods where class = '"+className+"'";
	}
	con.query(sql,function(err,rows,fields){
		callback(rows);
	})
}